﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Abp.ObjectMapping;
using CPPProject.CppModel;
using CPPProject.CppServices.Dto;
using Microsoft.EntityFrameworkCore;
using OplugAbpProject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace CPPProject.CppServices
{
    public class T_Biz_OrderAppService : AsyncCrudAppService<T_Biz_Order, T_Biz_OrderDto, Guid, PagedResultRequestDto, UpdateT_Biz_OrderDto, UpdateT_Biz_OrderDto>, IT_Biz_OrderAppService
    {
        private readonly IObjectMapper _objectMapper;
        public T_Biz_OrderAppService(IRepository<T_Biz_Order, Guid> repository, IObjectMapper objectMapper) : base(repository)
        {
            _objectMapper = objectMapper;
        }
        #region 订单管理
        /// <summary>
        /// 订单管理
        /// </summary>
        /// <param name="nCompanyID">公司ID</param>
        /// <param name="cName">下单人</param>
        /// <param name="UName">客户名称</param>
        /// <param name="cOrderCode">订单编号</param>
        /// <param name="dDate">下单日期</param>
        /// <param name="dDeliveryDate">订单交期</param>
        /// <param name="iType">类型（1发出2回收）</param>
        /// <param name="iStatus">订单状态（0待审核1确认审核2确认完成3已关闭4审核中）</param>
        /// <param name="skipCount"></param>
        /// <param name="maxResultCount"></param>
        /// <returns></returns>
        //public async Task<PagedResultDto<T_Biz_OrderDto>> GetList(string nCompanyID, string cName = "",string UName="",string cOrderCode="" ,string dDate="",string dDeliveryDate="",string iType="",string iStatus="", int skipCount = 0, int maxResultCount = 10)
        //{
        //    //PagedResultDto<T_Biz_OrderDto> resultDto = new PagedResultDto<T_Biz_OrderDto>();
        //    //List<T_Biz_Order> lists = new List<T_Biz_Order>();
        //    //Expression<Func<T_Biz_Order, bool>> expr = o => o.NCompanyID == nCompanyID;
        //    //if (!string.IsNullOrEmpty(cOrderCode))//订单编号
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.COrderCode == cOrderCode);
        //    //}
        //    //if (!string.IsNullOrEmpty(dDate))//下单日期
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.DDate.ToString() == dDate);
        //    //}
        //    //if (!string.IsNullOrEmpty(dDeliveryDate))//订单交期
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.DDeliveryDate.ToString() == dDeliveryDate);
        //    //}
        //    //if (!string.IsNullOrEmpty(iType))//类型（1发出2回收）
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.IType == iType);
        //    //}
        //    //if (!string.IsNullOrEmpty(iStatus))//订单状态（0待审核1确认审核2确认完成3已关闭4审核中）
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.IStatus == iStatus);
        //    //}
        //    //if (!string.IsNullOrEmpty(UName))//客户名称
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.t_Biz_Customer_CCusCode.CName == UName);
        //    //}
        //    //if (!string.IsNullOrEmpty(cName))//下单人
        //    //{
        //    //    expr = expr.ExpressionAnd(o => o.t_Sys_User.CName == cName);
        //    //}
        //    //lists = await Repository.GetAllIncluding(o=>o.t_Biz_Customer_CCusCode.CName,o=>o.t_Sys_User.CName).Where(expr).ToListAsync();
        //    //var dtos = lists.Skip(skipCount).Take(maxResultCount).ToList();
        //    //resultDto.Items = _objectMapper.Map<List<T_Biz_OrderDto>>(dtos);
        //    //resultDto.TotalCount = lists.Count;
        //    //return resultDto;
        //}
        #endregion
    }
}
